package in.muton.edushare.pages.publicpages.group;

import in.muton.edushare.pages.publicpages.UserSquareLink;
import in.muton.edushare.wicket.models.CayenneList;
import in.muton.panels.paginator.EdusharePageNavigator;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.PageableListView;
import org.apache.wicket.model.IModel;

import com.edushare.common.constants.ApplicationConstants;
import com.edushare.common.dao.GroupsMembersDAO;
import com.edushare.common.vo.GroupMembers;
import com.edushare.common.vo.Users;

public class GroupMembersPage extends GroupBase {

	public GroupMembersPage(PageParameters params) {
		super(params);
		CayenneList<Users> cl = new CayenneList<Users>(new GroupsMembersDAO(getSessionORMInterface()).getMembers(groupModel.getObject(), GroupMembers.STATUS_ACTIVE));
		PageableListView<IModel<Users>> ulist = new PageableListView<IModel<Users>>("memberList", cl, ApplicationConstants.PAGE_SIZE_THREE_A_ROW) {

			private static final long serialVersionUID = 6629080725384656502L;

			@Override
			protected void populateItem(ListItem<IModel<Users>> item) {
				item.add(new UserSquareLink("member", item.getModelObject()));
			}
		};
		
		add(ulist);
		add(new EdusharePageNavigator("pagination", ulist));
	}

	@Override
	public String getPageTitle() {
		return super.groupModel.getObject().getGroupName() + " | Members | " + ApplicationConstants.APPLICATION_NAME;
	}

}
